<template>
  <div class="big">
    <div v-if="rate.cRate > 0">
      <div class="top">
        <div class="left">用户评价</div>
        <div class="right">更多</div>
      </div>
      <div class="shop-top">
        <img v-lazy="rate.list[0].user.avatar" />
        <span class="title">{{ rate.list[0].user.uname }}</span>
      </div>
      <div class="content">
        <div class="content-1">
          {{ rate.list[0].content }}
        </div>
        <div class="content-2">
          <span class="showDate">{{ rate.list[0].created | showDate }}</span>
          <span>{{ rate.list[0].style }}</span>
        </div>
      </div>

      <div class="image">
        <div
          v-for="(image, index) in rate.list[0].images"
          :key="index"
          class="image-children"
        >
          <img v-lazy="image" @load="detailload" />
        </div>
      </div>
      <div></div>
    </div>
    <div v-else></div>
  </div>
</template>

<script>
import { formatDate } from "common/utils.js";
export default {
  props: ["rate"],
  methods: {
    detailload() {
      this.$bus.$emit("detailload");
    },
  },
  filters: {
    showDate(value) {
      let date = new Date(value * 1000);
      return formatDate(date, "yyyy-MM-dd");
    },
  },
};
</script>

<style scoped>
.big {
  border-bottom: 4px rgb(194, 192, 192, 0.2) solid;
}
.top {
  border-top: 3px rgb(139, 137, 137, 0.1) solid;
  height: 80px;
  width: 100%;
  text-align: center;
  line-height: 80px;
  border-bottom: 2px rgb(139, 137, 137, 0.1) solid;
  display: flex;
  justify-content: space-between;
}
.left {
  height: 80px;
  margin-left: 20px;
}
.right {
  font-size: 12px;
  height: 80px;
  margin-right: 20px;
}
.shop-top {
  line-height: 45px;
  /* 让元素垂直中心对齐 */
  display: flex;
  align-items: center;
  padding-top: 10px;
}

.shop-top img {
  margin-left: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.shop-top .title {
  margin-left: 10px;
  vertical-align: center;
}
.content {
  font-size: 12px;
  width: 100%;
}
.content-1 {
  padding: 10px 0 10px 20px;
}
.content-2 {
  padding: 10px 0 10px 20px;
  color: rgb(152, 171, 187);
}
.image {
  display: flex;
}
.image-children {
  flex-wrap: wrap;
  width: 120px;
  padding: 0 5px 0 5px;
}
.image-children img {
  width: 100%;
}
.showDate {
  padding-right: 10px;
}
</style>
